﻿@namespace MudBlazor.UnitTests.TestComponents

<MudTable T="Element" MultiSelection Comparer="Comparer">
    <HeaderContent>
        <MudTh>#</MudTh>
    </HeaderContent>
    <RowTemplate>
        <MudTd>@context.Value</MudTd>
    </RowTemplate>
</MudTable>

@code {
    public static string __description__ = "setting a comparer should be reflected in all layers of the table.";

    public ElementComparer Comparer = null;

    public void SetComparer() { Comparer = new(); StateHasChanged(); }

    public class ElementComparer : IEqualityComparer<Element>
    {
        public bool Equals(Element a, Element b) => a?.Id == b?.Id;
        public int GetHashCode(Element x) => HashCode.Combine(x?.Id);
    }

    public record Element
    {
        public string Id { get; set; }
        public string Value { get; set; }
    }
}